fix(parser): preserve glob in process substitution bodies#1337
Closed
fix(parser): preserve glob in process substitution bodies#1337
Conversation
Parser re-serialized tokens inside `<(cmd)` back into a string before handing the body to a child parser. For `QuotedGlobWord` tokens (e.g. `./"$var"*.ext`), re-serialization wrapped the *entire* token content in double quotes, which turned the unquoted glob `*` into a literal character. As a result, patterns like `< <(ls ./"$prefix"*.tmp.html)` silently matched nothing. Slice the process substitution body verbatim from the original source via the existing `source_slice()` helper instead of rebuilding it from tokens. The child parser now sees exactly what the user wrote, so quote boundaries and glob metacharacters are preserved. Net simplification: removes 180+ lines of token-to-string reconstruction, eliminates whole classes of future round-trip bugs. Closes #1333
Hosted runner was exhausting disk while compiling security_failpoint_tests (the 5th of 6 sequential cargo test stages with different feature flags). Reclaim ~25 GB of preinstalled SDKs before Rust compiles start.
Contributor
Author
|
Superseded by #1341 (merged), which applies the same fix (slice original source via span offsets). Closing. Generated by Claude Code |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1333. Glob metacharacters like
*adjacent to a quoted variable (e.g../"$var"*.ext) now expand correctly inside process substitution<(…)and>(…).Before this fix, patterns like
< <(ls ./"$prefix"*.tmp.html)silently matched nothing, even though the same pattern worked at the top level, inside$(...), inside(…), and inside{ …; } | ….Why
The parser re-serialised tokens inside
<(cmd)back into a string before handing the body to a child parser. ForQuotedGlobWordtokens (a word like./"$var"*.ext), re-serialization wrapped the entire token's content in double quotes:…which promoted the otherwise-unquoted
*into a literal character, so the inner parser's pathname-expansion check atexpand_command_argscorrectly decided not to glob.How
Replace the 180-line token-to-string reconstruction loop with a single call to the parser's existing
source_slice()helper: walk tokens to find the matching closing), then slice the body verbatim from the original source. The child parser now sees exactly what the user wrote, so quote boundaries and glob metacharacters are preserved byte-for-byte.TM-DOS-021(depth/fuel budget propagation to the child parser) is preserved.Test plan
process_subst_glob_adjacent_quoted_varandprocess_subst_glob_cattocrates/bashkit/tests/spec_cases/bash/procsub.test.sh— both previously failed and now passcargo test -p bashkit --test spec_tests bash_spec_tests✅cargo test -p bashkit --lib parser✅ (141 passed)cargo test -p bashkit --lib interpreter✅ (206 passed)bashkit -c '... < <(ls ./"$p"*.tmp.html | sort)'enumerates the expected filescargo fmt --check✅-130lines (parser code simplification)